import { mapState } from 'vuex'
import commonJs from '~/mixins/commonJs'
export default {
  computed: {
    ...mapState({
      locale: (state) => state.locale,
    }),
  },
  mixins: [commonJs],
  methods: {
    searchStatistics(target_url, tag, result_count, pageFrom) {
      try {
        let page = this.getCurPageName(pageFrom)
        let browserName = this.getBroswer()
        let deviceType = this.getDeviceType()
        const userLanguage = navigator.language || navigator.userLanguage
        let req = {
          page_name: page,
          url: window.location.href,
          target_url: target_url,
          referer: document.referrer || null,
          page_language: this.locale,
          browser_language: userLanguage,
          browser: browserName,
          device_type: deviceType,
          search_term: tag,
          search_result_count: result_count,
        }
        this.$axiosApi.postSa(req)
      } catch (error) {
        this.loadError()
      }
    },
  },
}
